#ifndef SHAREDCOUNTER_H_
#define SHAREDCOUNTER_H_

#include <unistd.h>
#include <sys/types.h>

#include "MemoriaCompartida.h"
#include "Semaforo.h"

class SharedCounter {
private:
	MemoriaCompartida<int> counter;
	Semaforo *mutex;
public:
	SharedCounter();
	SharedCounter(const std::string & file_path, char letra);
	virtual ~SharedCounter();
	void create(const std::string& archivo,const char letra);
	void increment(int inc = 1);
	void decrement(int dec = 1);
	void free_();
	void deleteMutex();
	static void init(SharedCounter & counter);
	int reed();

	static const std::string default_path;
};

#endif /* SHAREDCOUNTER_H_ */
